//
//  THIndicatorAnimateView.m
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 HZMengLiao. All rights reserved.
//
#import "THIndicatorAnimateView.h"
@interface THIndicatorAnimateView ()

@property (nonatomic,retain) UIActivityIndicatorView *indicatorView;

@property (nonatomic,retain) UILabel *textLable;
@end

@implementation THIndicatorAnimateView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI{
    self.indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    [self addSubview:self.indicatorView];
    
    self.textLable = [[UILabel alloc] initWithFrame:CGRectZero];
    self.textLable.font = kFontRegular(14);
    self.textLable.textColor = Color_text_99;
    self.textLable.textAlignment = NSTextAlignmentCenter;
    self.textLable.text = @"努力加载中";
    [self addSubview:self.textLable];
}
- (void)layoutSubviews{
    [super layoutSubviews];
    [self.indicatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self);
        make.height.width.mas_equalTo(44);
    }];
    [self.textLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.indicatorView.mas_bottom).offset(15);
    }];
}
- (void)startAnimating{
    if (self.alpha == 1.0) {
        return;
    }
    self.alpha = 1.0;
    [self.indicatorView startAnimating];
}
- (void)stopAnimating{
    [self.indicatorView stopAnimating];
    self.alpha = 0.0;
}

@end
